{include file='comdir/head.html'}
<body>
<div class="content">
	<div class="animated fadeInDown">
		<div class="pos"><a href="#" onClick="javascript :history.back(-1);">返回上一页</a></div>
	<div>
	<!-- 栏目类型分类 -->
	<form class="form-horizontal" action="javascript:void(0)" id='frm'>
	
	<div class="form-group">
		<label class="col-sm-2 control-label">站点选择</label>
		<div class="col-sm-5 add_sitesid">
			<select class="form-control sitesid_readonly" disabled name="sitesid">
				{foreach from=$sitesselected item=vo}
					<option {if $list.sitesid==$vo.id} selected{/if} value="{$vo.id}">{$vo.name}</option>
				{/foreach}
			</select>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">栏目分类</label>
		<div class="col-sm-5">
			<select class="form-control columnTypeselect" disabled name="coltype">
			<option {if $list.coltype==0}selected{/if} value="0">分类栏目</option>
			<option {if $list.coltype==1}selected{/if} value="1">系统栏目</option>
			<option {if $list.coltype==2}selected{/if} value="2">外链栏目</option>
		</select>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">栏目名称</label>
		<div class="col-sm-5">
			<input type="text" class="form-control" name="name" value="{$list.name|default:''}">
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">父栏目</label>
		<div class="col-sm-5">
			<select class="form-control parentid" name="parentid">
				{$getslected}
			</select>
		</div>
	</div>
	
	<div class="form-group img_show_hide" {if !isset($list)} style="display:none" {/if}>
		<label class="col-sm-2 control-label">显示图片</label>
		<div class="col-sm-5">
			<img class="show_column" style="width:100px;height:30px;margin-bottom: 5px;" src="{$getConfig.upload_http}{$list.photourl|default:''}" /><br />
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">上传文件</label>
		<div class="col-sm-5">
			<input type="hidden" value="{$list.photourl|default:''}" name="photourl" class="column">
			<div class="iframe-box btn-blue">
				<iframe id="upiframe" frameborder="0"  scrolling="no" src="{$_URL}Ups/upone?method=column&classname=column&callback=siteback"></iframe>
			</div>
		</div>
	</div>
	<div class="columnaddhtml">
	{if $list.coltype==0}{include file='column/comadd/typeadd.html'}{/if}
	{if $list.coltype==1}{include file='column/comadd/sysadd.html'}{/if}
	{if $list.coltype==2}{include file='column/comadd/linkadd.html'}{/if}
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">是否首页导航显示</label>
		<div class="col-sm-5">
			<div class="radio radio-inline">
				<input type="radio" id="showintop1" name="showintop" {if isset($list) && $list.showintop==1}checked{/if} value="1">
				<label for="showintop1">是</label>
			</div>
			<div class="radio radio-inline">
				<input type="radio" id="showintop2" {if isset($list) && $list.showintop==0}checked{/if} {if !isset($list)}checked{/if} name="showintop" value="0">
				<label for="showintop2">否</label>
			</div>
		</div>
	</div>
	<div class="form-group navimenu_show_hide">
		<label class="col-sm-2 control-label">首页下拉导航显示</label>
		<div class="col-sm-5">
			<div class="radio radio-inline">
				<input type="radio" id="navimenu1"  {if isset($list) && $list.navimenu==1}checked{/if}  name="navimenu" value="1">
				<label for="navimenu1">是</label>
			</div>
			<div class="radio radio-inline">
				<input type="radio" id="navimenu2"  {if isset($list) && $list.navimenu==0}checked{/if} {if !isset($list)}checked{/if} name="navimenu"  value="0">
				<label for="navimenu2">否</label>
			</div>
		</div>
	</div>
	<div class="form-group">
		<div class="col-sm-offset-2 col-sm-5">
			<input type="hidden" class="coltype" name="coltype" value='{$list.coltype}'>
			<input type="hidden" class="colid" name="colid" value='{$list.colid}'>
			<input type="button" class="btn btn-block btn-blue sub" name="name" value="提交">
		</div>
	</div>
	</form>

</div>
<script type="text/javascript">
var _URL='{$_URL}';
{literal}
function siteback(data){
	console.log(data);
	if(data.status){
		var classname=data.classname;
		$('.'+classname).val(data.img);
		$('.img_show_hide').show();
		$('.show_'+classname).attr('src',data.imgshow);
	}else{
		layer.msg(data.msg,{icon: 2}, function(){ return false;})
	}
}
$(function(){
	//栏目类型分类
	$('.columnTypeselect').change(function(){
		var add=$(this).val();
		var sitesid=$('.sitesid').val();
		$('.coltype').val(add);
		var url=_URL+"Column/add";
		_ajaxs.post(url,'type='+add+"&sitesid="+sitesid,function(data){
			$('.columnaddhtml').html('');
			$('.columnaddhtml').html(data);
		},'html');
	})
	// 首页下拉导航显示顶级菜单无选择
	$('.parentid').change(function(){
		var cur_parentid=$(this).val();
		var sitesid=$('.parentid').find('option:selected').attr('data-sites');
		if(cur_parentid!=0){ /*不是顶级栏目*/
			$('.navimenu_show_hide').show();

		}else{/*顶级栏目*/
			$('.navimenu_show_hide').hide();
			$('#navimenu2').prop('checked',true);
			
		}
	})
	//拷贝菜单显示与隐藏
	$('.iscopy').click(function(){
		var cur_iscopy=$(this).val();
		if(cur_iscopy==0){
			$('.copyid_show_hide').hide();
		}else{
			$('.copyid_show_hide').show();
		}
	})
	$('.sub').click(function(){
		var url=_URL+"Column/edit";
		var formjquery=_ajaxs.from('#frm');
		_ajaxs.post(url,'formjquery='+formjquery,function _result(data){
			ajax_status=true;
			layer.msg(data.msg,{icon: 1}, function(){
				if(data.status){
					window.location.href=_URL+"Column/lists";
				}
			});
		});
	})
	//系统栏目添加栏目列表模版和内容模版
	$('.add_collisttemplate').click(function(){
		var sitesid=$('.sitesid_readonly').val();
		if(!sitesid){
			sitesid=$('.addremovesitesid').val();
		}
		var url=_URL+"Column/select_template?type=list&sitesid="+sitesid;
		layer.open({
              type: 2,
              title: '选择模版',
              shadeClose: true,
              shade: false,
              maxmin: true, //开启最大化最小化按钮
              area: ['600px', '600px'],
              content:url,
            });
	})
	$('.add_contenttemplate').click(function(){
		var sitesid=$('.sitesid_readonly').val();
		if(!sitesid){
			sitesid=$('.addremovesitesid').val();
		}
		var url=_URL+"Column/select_template?type=content&sitesid="+sitesid;
		layer.open({
              type: 2,
              title: '选择模版',
              shadeClose: true,
              shade: false,
              maxmin: true, //开启最大化最小化按钮
              area: ['600px', '600px'],
              content:url,
            });
	})
	//更改站点时更新拷贝栏目选择
	$('.sitesid_readonly').change(function(){
			var sitesid=$(this).val();
			var coltype=$('.columnTypeselect').val();
			var url=_URL+"Column/add?iscopycolumn";
			_ajaxs.post(url,"iscopycolumn=1&sitesid="+sitesid+"&coltype="+coltype,function(data){
				if(data.status){
					$('.copyid').html('');
					$('.copyid').html(data.data.copyslected);
					$('.parentid').html('');
					$('.parentid').html(data.data.selected);
				}
			})
	})
})
{/literal}
</script>
</body>
</html>